package com.gxa.ssm251.service.impl;

import com.gxa.ssm251.mapper.UserMapper;
import com.gxa.ssm251.pojo.User;
import com.gxa.ssm251.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper= null;
//    开启事务的属性 rollbackFor是选择事务在发生什么异常时回滚   propagation是事务传播设置  isolation是事务隔离级别
    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
    @Override
    public User selectById(Integer id) {
        User user = userMapper.selectById(id);
        return user;
    }

    @Override
    public Integer insert(Integer id) {
//        Integer insert = userService.insert(id);
//        return insert;
        return null;
    }
}
